﻿using agsXMPP;
using agsXMPP.protocol.iq.disco;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace IMDemo
{
    /// <summary>
    /// LoginWindow.xaml 的交互逻辑
    /// </summary>
    public partial class LoginWindow : Window
    {
        private XmppClientConnection xmppClient;

        public LoginWindow()
        {
            this.InitializeComponent();
        }

        public LoginWindow(XmppClientConnection conn) : this()
        {
            this.xmppClient = conn;
        }

        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            Jid jid = new Jid(string.Format("{0}@{1}", this.txtUserName.Text.Trim(), this.txtServerIp.Text.Trim()));

            this.xmppClient.Server = jid.Server;
            this.xmppClient.Username = jid.User;
            this.xmppClient.Password = this.pwdBox.Password;
            this.xmppClient.Resource = jid.User;
            this.xmppClient.Priority = 10;
            this.xmppClient.Port = 5222;
            this.xmppClient.UseSSL = false;
            this.xmppClient.AutoResolveConnectServer = false;
            this.xmppClient.UseCompression = false;
            this.xmppClient.RegisterAccount = false;
            
            this.DialogResult = true;
        }
    }
}
